package JDBC;

import java.sql.*;
import java.util.Scanner;

public class statement {
    public static void main(String[] args) throws SQLException, ClassNotFoundException {


        Scanner sc=new Scanner(System.in);

        System.out.println("请输入账号：");
        String name = sc.nextLine();
        System.out.println("请输入密码：");
        int age=sc.nextInt();

        /*  方案1.DriverManager.registerDriver(new Driver());*/
      /*  方案2. new Driver();*/
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/student?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true", "root", "080666");

      /*  Properties info = new Properties();
        info.put("user", "root");
        info.put("password", "080666");
        Connection connection1 = DriverManager.getConnection("jdbc:mysql://localhost:3306/student?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true", info);

        Connection connection2 = DriverManager.getConnection("jdbc:mysql://localhost:3306/student?user=root&password=080666");
*/
        Statement statement = connection.createStatement();

        String sql="select * from table_name where name='"+name+"' and age='"+age+"';";
      /*  int i = statement.executeUpdate();*/
        ResultSet resultSet = statement.executeQuery(sql);
       /* while (resultSet.next()) {
            String name1 = resultSet.getString("name");
            int age1 = resultSet.getInt("age");
            int id = resultSet.getInt("id");
            System.out.println(name1+" "+age1+" "+id);
        }*/

        if(resultSet.next()){
            System.out.println("yes");
        }else
            System.out.println("no");

        resultSet.close();
        statement.close();
        connection.close();
    }
}
